function Bus () {
	this._events = {}
}
Bus.prototype.$on = function (eventName, callback) {
	if (typeof callback !== 'function') {
		throw new Error('callback is not a function')
	}
	if (this._events[eventName]) {
		this._events[eventName].push(callback)
	} else {
		this._events[eventName] = [callback]
	}
}
Bus.prototype.$emit = function (eventName, ...args) {
	if (this._events[eventName]) {
		this._events[eventName].forEach((cb) => {
			cb(...args)
		})
	}
}
Bus.prototype.$off = function (eventName, callback) {
	if (this._events[eventName]) {
		if (typeof callback !== 'function') {
			let ind = -1
			while (ind = this._events[eventName].indexOf(callback) >= 0) {
				this._events[eventName].splice(ind, 1)
			}
		} else {
			this._events[eventName] = []
		}
	}
}
export default new Bus()